Using the Color Picker Package
Using the Color Picker Package
Most applications only use the Color Picker Package to display the Color
Picker dialog box. A few applications may need to use the color model and
SmallFract conversion routines.
Presenting the Color Picker Dialog Box
Your application can present a user with the Color Picker dialog box by
using the GetColor function.
When called by your application, GetColor displays the dialog box, including
prompt text, which appears in the upper-left corner, and the starting color,
which appears in the lower of the two rectangles below the prompt. The color
that the user is selecting, displayed in the upper rectangle, ranges over the
entire color space in response to the controls in the rest of the dialog box. Your
application can supply the prompt text, the starting color, and the location of
the upper-left corner of the dialog box, and it can specify whether the dialog
box should appear on the main screen (the screen with the menu bar) or the
screen with the greatest pixel depth.
The two groups of numeric fields (Hue, Saturation, Brightness; Red, Green,
Blue) show the parameters of the color being picked in the two color models.
The user can increase or decrease the values using the arrow controls or can
enter values directly into any of the six fields.
The range for each of the component values is 0 to 65,535. Larger values are
truncated to 65,535 after the user exits the field. The hue value for pure red
is 0; pure green is 21,845; pure blue is 43,690. Hue values wrap around
from 0 to 65,535, so the user can circumnavigate the wheel with arrow
controls just as with the cursor. The user can select a single RGB value from
the Color QuickDraw range of 248 color values.
On black-and-white hardware (or in less than 4-bit mode), the display
appears in black and white; the Color Picker returns the RGB value selected,
but it does not call any color routines in the course of responding to user
actions.
On a device with a variable color look-up table (CLUT), the Color Picker
temporarily borrows a CLUT entry to display the exact color in the rectangle
that shows the color currently being picked. (If you let the
Color Manager approximate the user's value when your application
subsequently displays the chosen color, the result will probably differ
somewhat from the one picked.) The Color Picker re stores the color
environment when it is done.
Using Conversion Facilities
In addition to the GetColor function that displays the Color Picker dialog
box, the Color Picker Package provides six procedures for converting
between an RGB color record and a CMY, HLS, or HSV color record, and it
provides two functions that convert between SmallFract and fixed numbers.
Most applications are likely to use only the GetColor function.
The Color Picker Package defines the CMY color, HSL color, and HSV color
records with SmallFract values rather than integer values (as used in the RGB
color record). A SmallFract value is the fractional part-that is, the low-order
word-of a fixed number.
The integer values in the RGB color record are actually used as unsigned short
integer-sized values; by using SmallFract values, the
Color Picker Package avoids sign extension problems in the con version
math.
The Color Picker Package provides two functions for converting between
SmallFract and fixed numbers. Most applications do not need to use these
facilities.